// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Slm
{
	public sealed partial class Retention
	{
		[JsonInclude]
		[JsonPropertyName("expire_after")]
		public Elastic.Clients.Elasticsearch.Duration ExpireAfter { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_count")]
		public int MaxCount { get; set; }

		[JsonInclude]
		[JsonPropertyName("min_count")]
		public int MinCount { get; set; }
	}

	public sealed partial class RetentionDescriptor : SerializableDescriptorBase<RetentionDescriptor>
	{
		internal RetentionDescriptor(Action<RetentionDescriptor> configure) => configure.Invoke(this);
		public RetentionDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.Duration ExpireAfterValue { get; set; }

		private int MaxCountValue { get; set; }

		private int MinCountValue { get; set; }

		public RetentionDescriptor ExpireAfter(Elastic.Clients.Elasticsearch.Duration expireAfter)
		{
			ExpireAfterValue = expireAfter;
			return Self;
		}

		public RetentionDescriptor MaxCount(int maxCount)
		{
			MaxCountValue = maxCount;
			return Self;
		}

		public RetentionDescriptor MinCount(int minCount)
		{
			MinCountValue = minCount;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			writer.WritePropertyName("expire_after");
			JsonSerializer.Serialize(writer, ExpireAfterValue, options);
			writer.WritePropertyName("max_count");
			writer.WriteNumberValue(MaxCountValue);
			writer.WritePropertyName("min_count");
			writer.WriteNumberValue(MinCountValue);
			writer.WriteEndObject();
		}
	}
}